const express = require('express');
const router = express.Router();
//普通路由级别中间件,放在路由之前
let aa = function (req, res, next) {
  console.log('aaa');
  console.log('11111111');
  next()
}
router.use(aa);
router.get('/a', (req, res) => {
  throw new Error('error is finding')
  res.send('a')
})
router.post('/b', (req, res) => {
  res.send('b')
})
//错误中间件必须在路由的后面
let bb = function (err, req, res, next) {
  console.log('344444' + err.message);
  res.send('bb' + err.message)
}
router.use(bb);
module.exports = router;